package com.xs.aifitnessagent.util;

/**
 * 线程工具类
 *
 * @author lambor
 */
public class ThreadLocalUtil {

    /**
     * 线程变量
     */
    public static ThreadLocal<Integer> threadLocal = new InheritableThreadLocal<>();

    /**
     * 设置用户ID
     *
     * @param userId 用户ID
     */
    public static void setUserId(Integer userId) {
        threadLocal.set(userId);
    }

    /**
     * 获取用户ID
     *
     * @return 用户ID
     */
    public static Integer getUserId() {
        return threadLocal.get();
    }

    /**
     * 删除用户ID
     */
    public static void removeUserId() {
        threadLocal.remove();
    }
}
